﻿@using MVCExtension.Pager
@model IEnumerable<FTchinaMVC.Models.UserRole>

@{
    ViewBag.Title = "列表";
}

 
<table  class="tableBorder" >
            <tr align="center" valign="middle">
                <th colspan="2">
                     管 理
                </th>
            </tr>
            <tr>
                <td>
                    操作
                </td>
                <td>
                    
                   @Html.ActionLink("添加", "create", null,
            new Dictionary<string, object>() {   
{ "class", "easyui-linkbutton" },  
{"data-options", "plain:true,iconCls:'icon-add'"} ,
            })
            <a class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-reload'" href="#" onclick="Refresh()">刷新</a>
              @Html.ActionLink("导出Excel", "excel", null,
            new Dictionary<string, object>() {   
{ "class", "easyui-linkbutton" },  
{"data-options", "plain:true,iconCls:'icon-output'"} ,
{"model","false"}
            })
             <input type='checkbox' id='checkall' name='checkall' />全选/取消  
			<a class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-cancel'" 
               onclick="GroupDo('del')" href="#">删除</a>			 
                </td>
            </tr>
        </table>
		
		
<table class="tableBorder"   id="gvList" >
     <thead>
	<tr>
	<th>选择</th>
        <th>
            @Html.DisplayNameFor(model => model.RoleName)
        </th>
        <th>操作</th>
    </tr>
 </thead>
  <tbody>
@foreach (var item in Model) {
    <tr>
				<td>
                    <input type='checkbox' id='ids' name='ids' value='@item.ID' /></td>
               
        <td>
            @Html.DisplayFor(modelItem => item.RoleName)
        </td>
        <td>
            @Html.ActionLink(" ", "Edit", new RouteValueDictionary(new { id = item.ID }),
                        new Dictionary<string, object>  {   
							{ "class", "easyui-linkbutton" },  
							{"data-options", "plain:true,iconCls:'icon-edit'"} ,
                            {"title","编辑" }})&nbsp;
                    @Html.ActionLink(" ", "Details", new RouteValueDictionary(new { id = item.ID }),
                        new Dictionary<string, object>  {   
							{ "class", "easyui-linkbutton" },  
							{"data-options", "plain:true,iconCls:'icon-note'"} ,
                            {"title","查看" }})&nbsp;
                    @Html.ActionLink(" ", "Delete", new RouteValueDictionary(new { id = item.ID }),
                        new Dictionary<string, object>  {   
							{ "class", "easyui-linkbutton" },                             
							{"data-options", "plain:true,iconCls:'icon-cancel'"} ,
                            {"title","删除" }})
			 
        </td>
    </tr>
}
 </tbody>
</table>
@Html.Pager((int)ViewBag.ItemsCount, (int)ViewBag.PageSize, (int)ViewBag.PageIndex,"index","UserRole",
 new PagerOptions
 {
     CssClass = "pager",
     PageIndexParameterName = "id",
     MorePagerItemWrapperFormatString = "<li>{0}</li>",
     CurrentPagerItemWrapperFormatString = "<li class='p_current'>{0}</li>",
     NumericPagerItemWrapperFormatString = "<li>{0}</li>",
     NavigationPagerItemWrapperFormatString = "<li>{0}</li>",
     AlwaysShowFirstLastPageNumber = true,
     ShowPageIndexBox = true,
     PageIndexBoxType = PageIndexBoxType.TextBox,
     PageIndexBoxWrapperFormatString = "{0}",
     GoToPageSectionWrapperFormatString = "<li>{0}</li>",
     ShowGoButton = false,
     ShowFirstLast = false,
     SeparatorHtml = "",
 }, "Default", null, null)
<div style="color: Gray">提示：点击表头可以排序</div>
<div id="results" class="hidden"></div>
@section scripts {
    <script src="/Scripts/easyui/jquery.easyui.min.js"></script>
    <link href="/Scripts/easyui/themes/default/linkbutton.css" rel="stylesheet" />
    <link href="/Scripts/easyui/themes/icon.css" rel="stylesheet" />
    <script src="http://cloud.github.com/downloads/ericmmartin/simplemodal/jquery.simplemodal.1.4.3.min.js"></script>

    <script type="text/javascript" type="text/javascript">
        $(function () {
            $("#gvList").tablesorter();
            $("#gvList th").css("cursor", "pointer");
			TableColorDefault("gvList");
			$(".easyui-linkbutton").click(function () {               
                ShowModel($(this).attr("href"), $(this).attr("model"));
                return false;
            }); 
			//全选
			$("#checkall").click(function () {
                if (this.checked) {
                    $("input[name='ids']").each(function () { this.checked = true; });
                } else {
                    $("input[name='ids']").each(function () { this.checked = false; });
                }
            });					
        });		
		//批量操作
			function GroupDo(optype) {
            var chk_value = '';
            $('input[name="ids"]:checked').each(function () {
                chk_value = $(this).val() + "," + chk_value;
            });//获取选中的项目
            if (chk_value.length > 0) {
                var url = '/@ViewBag.ControllerName/GroupProcess';
                $.ajax({
                    url: url,
                    type: "POST",
                    data: { ids: chk_value, optype: 'del' },
                    cache: false,
                    success: function (html) {
                        alert(html);
                    }
                });
                location.href = "/@ViewBag.ControllerName/index/@ViewBag.PageIndex";
            }
            else {
                alert("请至少选择一项");
            }
			}		
    </script>
}
